﻿@model CardInChina.Bussiness.Frontend.Models.CustomerFavoriteInfoInUserWelcome
@{
    ViewBag.Navi = "#ui-favorite";
    Layout = "~/Views/Shared/_User.cshtml";
}

<script type="text/javascript">
    $(function () {

        $("select.products_name_chose").bind("change", function (e) {
            var select = $(this);
            var currency_type = select.val();
            var currency_type_str = select.children("option:selected").text();
                 var cardid = $(this).parent().prev().attr('id');
                 var params = '{CurrencyType:"' + currency_type + '",CardID:"' + cardid + '"}';
                 $.ajax({
                    type: "POST",
                    cache:false,
                    url: "@Url.Action("GetCardPriceInfo", "Exchange")",
                    data: params,
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    success: function (result) {
                        var commonprice = result.CommomPrice;
                        var vipprice = result.VIPPrice;
                        select.parent().next().next().html(commonprice + '<br/>' + vipprice);
                    },
                    error: function (xhr, msg, e) {
                        alert(msg);
                    }
                 });

             });
        
        $("a.purchaseC").bind("click",function(){
            var src = $(this).attr("href");
            //select
            var select = $(this).parent().prev().prev().prev().children().first();
            var selectVal = select.val();
            location.href = src + "/" + selectVal;
            return false;
        });

        //<input id="btnClose" type="button" value="删除" class="btnClose ui-icons" />
        $("input.btnClose").bind("click",function(){
           
           if(!confirm("您确实要取消对该商品的收藏吗？")) return false;
           var faid = $(this).parent().parent().attr("id");
           var cardid = $(this).parent().parent().children().first().attr("id");
           var params = '{favoriteID:"' + faid + '",cardID:"' + cardid + '"}';
            $.ajax({
                    type: "POST",
                    cache:false,
                    url: "@Url.Action("Delete", "Favorite")",
                    data: params,
                    dataType: "html",
                    contentType: "application/json; charset=utf-8",
                    success: function (result) {
                        showAjaxDialog(result,true);
                        window.location.reload();
                    },
                    error: function (xhr, msg, e) {
                        alert(msg);
                    }
                 });
            
        });
    });
</script>

<div class="myhome_center" style="width: 720px;">
    <div class="full">
        <div class="tou">
            <h2>
                我的收藏</h2>
        </div>
        <div class="form">
            <div class="introduc_info-usr">
            @if (Model.Favorites.Count == 0)
            {                
                <div class="m_y">
                    <h2>
                        您的收藏夹里还没有宝贝喔！赶紧添加吧！</h2>
                </div>
            }
            else
            {
                <div class="tab2_area">
                    <ul class="tab2_head tabs">
                        <li class=""><a href="#tab1">游戏卡</a></li>
                        <li class=""><a href="#tab2">代购商品</a></li>
                    </ul>
                </div>
                <div class="tab2_container">
                    <div class="introduc_area tab2_content" id="tab1">
                        <div class="introduc_areaT">
                        </div>
                        <div class="introduc_area_bg">
                            <table class="mytobepaid_list2" border="0" cellspacing="0" cellpadding="0">
                                <tbody>
                                    <tr class="mytobepaid_title2">
@*                                        <th class="list_list2">
                                            &nbsp;
                                        </th>*@
                                        <th class="list_Infor2">
                                            商品信息
                                        </th>
                                        <th></th>
                                        <th class="list_total2" colspan="2">
                                            价格
                                        </th>
                                        <th class="list_operation2">
                                            操作
                                        </th>
                                    </tr>
                                    @foreach (var c in Model.Favorites
                                        .OrderByDescending(p=>p.CreateTime)
                                        .Skip(((int)ViewBag.Page - 1) * CustomHtmlHelper.PageCount)
                                        .Take(CustomHtmlHelper.PageCount))
                                    {
                                        <tr id="@c.FavoriteID">
@*                                            <td class="list_list2">
                                                <input name="cbSel" type="checkbox" value="@c.CardID" id="" />
                                            </td>*@
                                            <td class="list_Infor2" id="@c.CardID">
                                            <div class="pic"><a href="@Url.Action("Index", "CardDetail", new { cardKey = c.CardInfoKey })">
                                                <img src="/content/images/photo/@c.Photo" alt="" /></a></div>
                                            <div class="sm">
                                                <h2>
                                                @Html.ActionLink(c.CardInfoName, "Index", "CardDetail", new { cardKey = c.CardInfoKey }, null)
                                                    </h2>
                                                <p>
                                                   @c.CardName</p>
                                            </div>
                                        </td>
                                            <td class="list_total2">
                                                <select class="products_name_chose">
                                                    <option value="1">美元</option>
                                                    <option value="2">加元</option>
                                                    <option value="3">英磅</option>
                                                    <option value="4">欧元</option>
                                                    <option value="5">澳元</option>
                                                    <option value="6">日元</option>
                                                    <option value="7">新元</option>
                                                    <option value="8" selected="selected">人民币</option>
                                                </select>
                                            </td>
                                        <td class="list_total2">
                                        会员价：<br />VIP价：
                                        </td>
                                        <td class="list_total2">
                                            @c.Price <br /> @c.VIPPrice
                                        </td>
                                        <td class="list_operation2">
                                            @Html.ActionLink("购买", "Index", "Purchase", 
                                                new { commodity = c.CardInfoKey,type = c.CardKey },
                                                 new { @class = "btnPay ui-icons purchaseC" })
                                            <input id="btnClose" type="button" value="删除" class="btnClose ui-icons" />
                                        </td>
                                        </tr> 
                                    }
                                </tbody>
                            </table>
                            <div class="fy">
                                <div class="">
                                    @Html.CustomPaging(Model.Favorites.Count, CustomHtmlHelper.PageCount, (int)ViewBag.Page,
                                        i => Url.Action("Favorite", "Customer", new { page = i}))
                                </div>
                            </div>
                        </div>
                        <div class="introduc_areaD">
                        </div>
                    </div>
                    <div class="introduc_area tab2_content" id="tab2">
                        <div class="introduc_areaT">
                        </div>
                        <div class="introduc_area_bg">
                            <table class="mytobepaid_list2" border="0" cellspacing="0" cellpadding="0">
                                <tbody>
                                    <tr class="mytobepaid_title2">
                                        <th class="list_list2">
                                            &nbsp;
                                        </th>
                                        <th class="list_Infor2">
                                            商品信息
                                        </th>
                                        <th class="list_total2">
                                            价格
                                        </th>
                                        <th class="list_operation2">
                                            操作
                                        </th>
                                    </tr>
                                    <tr id="">
                                        <td class="list_list2">
                                            <input name="cbSel" type="checkbox" value="" id="Checkbox2" />
                                        </td>
                                        <td class="list_Infor2">
                                            <div class="pic">
                                                <img src="/content/images/ss.gif" alt="" /></div>
                                            <div class="sm">
                                                <h2>
                                                    <a href="">魔兽世界(战网)</a></h2>
                                                <p>
                                                    魔兽世界-直充(直充)-30元</p>
                                            </div>
                                        </td>
                                        <td class="list_total2">
                                            $6.23
                                        </td>
                                        <td class="list_operation2">
                                            <input id="" type="submit" value="购买" class="btnPay ui-icons" />
                                            <input id="" type="reset" value="删除" class="btnClose ui-icons" />
                                        </td>
                                    </tr>
                                    <tr id="">
                                        <td class="list_list2">
                                            <input name="cbSel" type="checkbox" value="" id="Checkbox3" />
                                        </td>
                                        <td class="list_Infor2">
                                            <div class="pic">
                                                <img src="/content/images/ss.gif" alt="" /></div>
                                            <div class="sm">
                                                <h2>
                                                    <a href="">魔兽世界(战网)</a></h2>
                                                <p>
                                                    魔兽世界-直充(直充)-60元魔兽世界-直充(直充)-60元魔兽世界-直充(直充)-60元</p>
                                            </div>
                                        </td>
                                        <td class="list_total2">
                                            $60.23
                                        </td>
                                        <td class="list_operation2">
                                            <input id="" type="submit" value="购买" class="btnPay ui-icons" />
                                            <input id="" type="reset" value="删除" class="btnClose ui-icons" />
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <div class="fy">
                                <div class="kz">
                                    <input name="cbSel" type="checkbox" value="" id="Checkbox4" />
                                    全选
                                    <input id="" type="reset" value="批量删除" class="com_payment ui-icons" />
                                </div>
                                <div class="">
                                    <div class="page-bottom">
                                        <input id="" type="reset" value="上一页" class="page-start ui-icons" />
                                        <input id="" type="reset" value="1" class="page-cur ui-icons" />
                                        <input id="" type="reset" value="2" class="page-next ui-icons" />
                                        <input id="" type="reset" value="下一页" class="page-end ui-icons" />
                                        <span class="page-skip">共2页 到第
                                            <input id="" type="text" value="" class="jumpto ui-icons" />
                                            页 </span>
                                        <input id="" type="reset" value="Go" class="page-Go ui-icons" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="introduc_areaD">
                        </div>
                    </div>
                </div>
            }
            </div>
        </div>
    </div>
</div>
